package com.stylefeng.guns.modular.system.controller;

import com.stylefeng.guns.core.base.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.stylefeng.guns.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestParam;
import com.stylefeng.guns.modular.system.model.BusinessTypeBase;
import com.stylefeng.guns.modular.system.service.IBusinessTypeBaseService;

/**
 * 项目分类表 控制器
 *
 * @author fengshuonan
 * @Date 2019-09-23 22:52:39
 */
@Controller
@RequestMapping("/businessTypeBase")
public class BusinessTypeBaseController extends BaseController {

    private String PREFIX = "/system/businessTypeBase/";

    @Autowired
    private IBusinessTypeBaseService businessTypeBaseService;

    /**
     * 跳转到项目分类表 首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "businessTypeBase.html";
    }

    /**
     * 跳转到添加项目分类表 
     */
    @RequestMapping("/businessTypeBase_add")
    public String businessTypeBaseAdd() {
        return PREFIX + "businessTypeBase_add.html";
    }

    /**
     * 跳转到修改项目分类表 
     */
    @RequestMapping("/businessTypeBase_update/{businessTypeBaseId}")
    public String businessTypeBaseUpdate(@PathVariable Integer businessTypeBaseId, Model model) {
        BusinessTypeBase businessTypeBase = businessTypeBaseService.selectById(businessTypeBaseId);
        model.addAttribute("item",businessTypeBase);
        LogObjectHolder.me().set(businessTypeBase);
        return PREFIX + "businessTypeBase_edit.html";
    }

    /**
     * 获取项目分类表 列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        return businessTypeBaseService.selectList(null);
    }

    /**
     * 新增项目分类表 
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(BusinessTypeBase businessTypeBase) {
        businessTypeBaseService.insert(businessTypeBase);
        return SUCCESS_TIP;
    }

    /**
     * 删除项目分类表 
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer businessTypeBaseId) {
        businessTypeBaseService.deleteById(businessTypeBaseId);
        return SUCCESS_TIP;
    }

    /**
     * 修改项目分类表 
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(BusinessTypeBase businessTypeBase) {
        businessTypeBaseService.updateById(businessTypeBase);
        return SUCCESS_TIP;
    }

    /**
     * 项目分类表 详情
     */
    @RequestMapping(value = "/detail/{businessTypeBaseId}")
    @ResponseBody
    public Object detail(@PathVariable("businessTypeBaseId") Integer businessTypeBaseId) {
        return businessTypeBaseService.selectById(businessTypeBaseId);
    }
}
